home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MCASM.RAR / MC_ASM.EXE / WROX_ASM / CH11 / SHHCTEST.ASM next >
Assembly Source File  |  1994-08-25  |  6KB  |  185 lines

  1. ;*** WROX Tests *************************************************************
  2. ;
  3. ;  SVGA - HiColor Modes - Address Calculation and Pixel Writting - S.Herd
  4. ;
  5. ;----------------------------------------------------------------------------
  6. ;
  7. ;  Description:
  8. ;     The program draws a diagonal line from top-left corner of screen to
  9. ;     the bottom-right hand corner using code within the DRAW_LINE loop
  10. ;     (this tests banks are switched correctly). By pressing return each
  11. ;     time the line has been drawn the value of the 5 bit Blue component
  12. ;     (within the RGB Word to be written to Video memory) is incremented
  13. ;     (this happens 16 times i.e. Blue = 0 to 15) to test that the blue
  14. ;     intensity of the line increases as would be expected from reading the
  15. ;     text in chapter 11.
  16. ;
  17. ;----------------------------------------------------------------------------
  18. ;
  19. ;  Results:
  20. ;     Instead of the line getting bluer and bluer as the Blue value
  21. ;     increased - the color simply cycles through the standard colours
  22. ;     (i.e. 0 = black, 1 = blue, 2 = green, 3 = cyan etc.) suggesting that
  23. ;     the color is being treated the same as in 256 color modes.
  24. ;
  25. ;     In addtion to this, other tests show that writting:
  26. ;
  27. ;                    mov   es:[bx],0001h
  28. ;
  29. ;     will light one pixel (blue) and
  30. ;
  31. ;                    mov es:[bx],0101h
  32. ;
  33. ;     will light two consequative pixels (both blue), suggesting that
  34. ;
  35. ;                    bytes per line = pixels per line
  36. ;
  37. ;     and not
  38. ;                    bytes per line = pixels per line * 2
  39. ;
  40. ;     as suggested for hicolor modes.
  41. ;
  42. ;----------------------------------------------------------------------------
  43. ;
  44. ;  Equipment tested on:
  45. ;     Adapter: TRIDENT TVGA9000 (VP90B)
  46. ;     Bios   : TRIDENT TVGA BIOS D3.0
  47. ;              512k  VGA mode
  48. ;
  49. ;----------------------------------------------------------------------------
  50. ;
  51. ;  Vesatest.exe report:
  52. ;
  53. ; VESA BIOS extension version 1.2 is installed.
  54. ; OEM string is : Copyright 1988-1991 TRIDENT MICROSYSTEMS INC.
  55. ;
  56. ; Device capabilities are 00000000
  57. ; Installed video memory size (in Kb) : 512
  58. ; Mode Attr WindowA WindowB Window Mem contr BPL  Format   Char   BPP  MM   Pg
  59. ;           att seg att seg gr siz    call                 Cell NBP  Bnks SoB
  60. ; 0170 H CG RW A000         64 64  3571:192A 1024 512x480  8x16 1 16 1 06 0 1
  61. ; 0171 H CG RW A000         64 64  3571:192A 1024 512x480  8x16 1 16 1 06 0 1
  62. ; 0100 HBCG RW A000         64 64  3571:192A 640  640x400  8x16 1 8  1 04 0 1
  63. ; 0101 HBCG RW A000         64 64  3571:192A 640  640x480  8x16 1 8  1 04 0 1
  64. ; 0103 HBCG RW A000         64 64  3571:192A 800  800x600  8x16 1 8  1 04 0 1
  65. ; 0104 HBCG RW A000         64 64  3571:192A 128  1024x768 8x16 4 4  1 03 0 1
  66. ; 0102 HBCG RW A000         64 64  3571:192A 100  800x600  8x16 4 4  1 03 0 1
  67. ; 006A HBCG RW A000         64 64  3571:192A 100  800x600  8x16 4 4  1 03 0 1
  68. ; 0108 HBCT RW A000         64 64  3571:192A 160  80x60    8x16 4 4  1 00 0 2
  69. ; 0109 HBCT RW A000         64 64  3571:192A 264  132x25   8x16 4 4  1 00 0 2
  70. ; 010A HBCT RW A000         64 64  3571:192A 264  132x43   8x16 4 4  1 00 0 2
  71. ; 010B HBCT RW A000         64 64  3571:192A 264  132x50   8x16 4 4  1 00 0 2
  72. ; 010C HBCT RW A000         64 64  3571:192A 264  132x60   8x16 4 4  1 00 0 2
  73. ;
  74. ;****************************************************************************
  75.  DOSSEG
  76.  
  77. .MODEL SMALL
  78. .STACK 100h
  79. .DATA
  80.  
  81. Y        dw 0
  82. X        dw 0
  83.  
  84. Blue     db 0
  85. Red      db 0
  86. Green    db 0
  87.  
  88. Mode     dw 171h        ;64k Colors 512 x 480 HiColor
  89. BytesPL  dw 1024        ;Bytes Per Line - abtained via 'Vesatest.exe'
  90. Rows     dw 480
  91.  
  92. .CODE
  93. .386
  94.  
  95. ;--- MAIN PROGRAM
  96.  
  97.    push  bx
  98.    push  cx
  99.    push  dx
  100.    push  si
  101.    push  di
  102.    push  ds
  103.    push  es
  104.  
  105.    ;--- Address data segment
  106.    mov   ax,@data
  107.    mov   ds,ax
  108.  
  109.    ;--- Set VESA Video Mode
  110.    mov   ax,4f02h
  111.    mov   bx,Mode
  112.    int   10h
  113.  
  114.    ;--- Address video memory
  115.    mov   ax,0a000h
  116.    mov   es,ax
  117.  
  118. NEXT_COLOR:
  119.    ;--- Draw a diagonal line
  120.    mov   Y,0
  121.    mov   X,0
  122.  
  123. DRAW_LINE:
  124.    ;--- Calculate pixel address
  125.    mov   ax,Y     ;AX = Y coordinate
  126.    mov   bx,X     ;BX = X coordinate
  127.    mul   BytesPL  ;AX = row offset in video memory from
  128.                   ;the beginning of the bank Lo(Y * BytesPerLine)
  129.                   ;DX = bank number Hi(Y * BytesPerLine)
  130.    shl   bx,1     ;BX = X * 2 (word per pixel)
  131.    add   bx,ax    ;BX = word offset in video memory from
  132.                   ;the beginning of the bank
  133.    adc   dx,0     ;bank-split-row catching
  134.  
  135.    push  bx
  136.  
  137.    xor   bx,bx
  138.    mov   ax,4f05h       ;--- Switch Bank
  139.    int   10h
  140.  
  141.    ;--- Write Pixel
  142.    mov   al,Blue        ;AL = blue component of pixel color
  143.    mov   ah,Red         ;AH = red component of pixel color
  144.    shl   ah,3           ;shift by 2 if 32K colors, by 3 if 64K
  145.    movzx bx,Green       ;BX = green component of pixel color
  146.    shl   bx,5
  147.    or    ax,bx
  148.  
  149.    pop   bx
  150.    mov   es:[bx],ax     ;<== WRITE PIXEL HERE
  151.  
  152.    inc   X
  153.    inc   Y
  154.    mov   ax,Rows
  155.    cmp   Y,ax
  156.    jne   DRAW_LINE
  157.  
  158.    ;--- Line Drawn - Wait for Keypress...
  159.    mov   ah,8
  160.    int   21h
  161.  
  162.    ;--- Select Next Color
  163.    inc   Blue
  164.    cmp   Blue,16
  165.    jne   NEXT_COLOR
  166.  
  167.    ;--- Reset Video Mode
  168.    mov   ax,0003h
  169.    int   10h
  170.  
  171.    pop   es
  172.    pop   ds
  173.    pop   di
  174.    pop   si
  175.    pop   dx
  176.    pop   cx
  177.    pop   bx
  178.  
  179.    mov ax,4c00h      ; Exit program
  180.    int 21h
  181.  
  182. END
  183.  
  184. ;****************************************************************************
  185.